package top.hudk.polymorphic;

/**
 * 作用：字段不参与多态
 *
 * @author hudk
 * @date 2020/5/22 15:53
 */
public class FieldHasNoPolymorphic {

    static class Father {
        public int money = 1;
        public Father() {
            money = 2;
            showMeTheMoney();
        }
        public void showMeTheMoney() {
            System.out.println(money);
        }
        public int getMoney(){
            return money;
        }
    }

    static class Son extends Father {
        public int money = 3;
        public Son() {
            money = 4;
            showMeTheMoney();
        }
        @Override
        public void showMeTheMoney() {
            System.out.println(money);
        }
//        @Override
//        public int getMoney(){
//            return super.money;
//        }
    }
//    public static void main(String[] args) {
//        Father gay = new Son();
//        System.out.println(gay.money);
//        System.out.println(gay.getMoney());
//    }
}